package com.freshcity.manager.support
{
	import com.freshcity.common.LoadEffectCircle;
	import com.freshcity.manager.LayerManager;
	
	import flash.display.DisplayObject;
	import flash.display.DisplayObjectContainer;
	import flash.display.Shape;
	import flash.display.Sprite;
	
	public class LoadEffect extends Sprite
	{
		public function LoadEffect()
		{
			this.name="loadCircle";
		}
		
		public function show(host:DisplayObjectContainer=null):void
		{
			var back:Sprite = new Sprite();
			addChild(back);
			var circle:LoadEffectCircle = new LoadEffectCircle();
			addChild(circle);
			
			
			if(host){
				host.addChild(this);
				back.graphics.beginFill(0, 0);
				back.graphics.drawRect(0, 0, host.width, host.height);
				back.graphics.endFill();
				
				circle.x = (host.width-circle.width)/2;
				circle.y = (host.height-circle.height)/2;
			}else{
				LayerManager.highestLayer.addChild(this);
				back.graphics.beginFill(0, 0);
				back.graphics.drawRect(0, 0, this.stage.stageWidth, this.stage.stageHeight);
				back.graphics.endFill();
				
				circle.x = (this.stage.stageWidth-circle.width)/2;
				circle.y = (this.stage.stageHeight-circle.height)/2;
			}
		}
		
		public function hide():void
		{
			while(this.numChildren>0){
				this.removeChildAt(this.numChildren-1);
			}
			if(this.parent)this.parent.removeChild(this);
		}
	}
}